#include<queue>
#include<vector>
class Solution {
public:
    int lastStoneWeight(std::vector<int>& stones) {
        std::priority_queue<int> que;
        for (auto& e : stones)
            que.push(e);
        while (que.size() != 1) {
            int x = que.top();
            que.pop();
            int y = que.top();
            int t = x - y;
            que.pop();
            que.push(t);
        }
        return que.top();
    }
};